#define  _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

void Swap(int* p1, int* p2)
{
    int tmp = *p1;
    *p1 = *p2;
    *p2 = tmp;
}

void RowTrans(int arr[10][10], int row1, int row2)
{
    for (int i = 0;i < 10;i++)
    {
        Swap(&arr[row1][i], &arr[row2][i]);
    }
}

void ColTrans(int arr[10][10], int col1, int col2)
{
    for (int i = 0;i < 10;i++)
    {
        Swap(&arr[i][col1], &arr[i][col2]);
    }
}

int main()
{
    int n = 0;
    int m = 0;
    scanf("%d %d", &n, &m);
    int arr[10][10];

    for (int i = 0;i < n;i++)
    {
        for (int j = 0;j < m;j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }

    int k = 0;
    scanf("%d", &k);
    char ch = 0;
    int a, b;
    while (k--)
    {
        scanf(" %c", &ch);
        scanf("%d%d", &a, &b);
        switch (ch)
        {
        case 'r':
            RowTrans(arr, a - 1, b - 1);
            break;
        case 'c':
            ColTrans(arr, a - 1, b - 1);
            break;
        case 't':
            break;
        default:
            break;
        }
    }

    for (int i = 0;i < n;i++)
    {
        for (int j = 0;j < m;j++)
        {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }

    return 0;
}